#!/bin/bash

#here it may check if pthread was requested
#threaded=pt
threaded=

# first static libraries are considered, next links to more specific versions
liblapack=$(locate lib${threaded}lapack | sort | head -1)

if [ $liblapack ]
then
  if [[ $(file $(readlink -f $liblapack)) =~ 'dynamically linked' ]]
  then
    ext=so
  else
    ext=a
  fi
  # remove existing file (-f)
  mkdir -p $(adapt query sys/prefix)/lib
  ln -s -f $liblapack $_/liblapack.$ext
  # register the library. inc is not defined
  adapt register self
else
  exit 1
fi
